﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;

/// <summary>
/// Description résumée de ActiviteService
/// </summary>
/// 
namespace BLL
{
    public class ActiviteService
    {
        private IActiviteManager activiteManager;
        private ISiteManager siteManager;

        public ActiviteService(IActiviteManager activiteManager, SiteManager siteManager)
        {
            this.activiteManager = activiteManager;
            this.siteManager = siteManager;
        }

        public ACTIVITE createActivite(string nom)
        {
            ACTIVITE activite = new ACTIVITE();
            activite.NOM = nom;

            try
            {
                this.activiteManager.addActivite(activite);
                return activite;
            }

            catch (Exception ex)
            {
                return null;
            }

        }

        public bool deleteActivite(int activiteId)
        {
            return activiteManager.deleteActivite(activiteId);
        }

        public List<ACTIVITE> getAllActivites()
        {
            return activiteManager.getAllActivites();
        }

        public bool updateActivite(int id, string nom)
        {
            try
            {
                ACTIVITE activite = activiteManager.getActiviteById(id);
                activite.NOM = nom;

                activiteManager.updateActivite();

                return true;
            }

            catch (Exception ex)
            {
                return false;
            }
        }

        public List<ACTIVITE> getActivitesOnSite(int siteId)
        {
            return this.activiteManager.getActivitesOnSite(siteId);
        }

        public bool addActiviteOnSite(int siteId, int activiteId)
        {
            return this.activiteManager.addActiviteOnSite(siteId, activiteId);
        }

        public bool removeActiviteOnSite(int siteId, int activiteId)
        {
            return this.activiteManager.removeActiviteOnSite(siteId, activiteId);
        }

        public ACTIVITE getActiviteById(int id)
        {
            return this.activiteManager.getActiviteById(id);
        }

        public string getNom(int id)
        {
            return this.activiteManager.getNom(id);
        }

        public ACTIVITE getActiviteByNom(string nom)
        {
            return activiteManager.getActiviteByNom(nom);
        }
    }
}